/*	main.c 
 *  Arizona State University
 *  CSE 325: Embedded Systems Programming
 *  Lab 6: Nunchuk Pacman
 *  Georgii Tkachuk, Brentton Garber
 *   Emails: 	gtkachuk@asu.edu btgarber@asu.edu
 * 	Description: 
 * 	Nunchuk Pacman. The program uses i2c module to read joystick moves from the wii nunchuk. The joystick actions control the Pacman(orange dot) that is displayed 
 * 					on the LED matrix (using qspi module). The ghosts(red dots) chase the player using patterns specified in the game.c module. Green dots represent 
 * 					the barrier that can't be passed by the ghosts nor the player. 
 * 					the game utilizes two buttons.	Button 1 is used to increase the number of ghosts after the next reset.
 * 													Button 2 resets the game.
 * 					If a ghost catches the pacman the game is over. To play again press button 2 to reset the game. 
 * 
 * 
 * 
 * 	Main module. Initializes all components and starts the game. 
 * 
 */


#include "support_common.h" /* include peripheral declarations and more */
#if (CONSOLE_IO_SUPPORT || ENABLE_UART_SUPPORT)
/* Standard IO is only possible if Console or UART support is enabled. */
#include <stdio.h>
#endif

#include "support_common.h"
#include "common.h"

// Initialize our components
static void init()
{
	pwm_init();
	nunchuk_init();
	ledmatrix_init();			// Initialize the LED Matrix
	gpt_init();					// Initialize the gpt
	pit_init();					// Initialize the pit
	
	int_uninhibit_all();		// uninhibit all
}

// Calls init() to initialize the hardware, Starts the game, then drops into an infinite loop.
int main(void)
{
	// Initialize the components
	init();
	
	// automatically play the game when started
	game_reset();
	
	// Keep the program running
	while (1) { }
	
	return 0;
}